﻿
function UpdateVocational(element) {
    var vocational = document.getElementById("Vocational");
    var selectedValue = element[element.selectedIndex].value;
    if (selectedValue == "GCE" || selectedValue == "GCSE" || selectedValue == "O-Level" || selectedValue == "A-Level") {
        vocational.innerText = "False";
    }
    else {
        vocational.innerText = "True";
    }
}

function UpdateVerified(element) {
    var controlTypeName = element.id.replace("VerificationType", "") + "Verified";
    var verifiedControl = document.getElementById(controlTypeName);
    var selectedValue = element[element.selectedIndex].value;
    if (selectedValue == "Please select an option from the list") {
        verifiedControl.value = "False";
        verifiedControl.style.borderColor = "#B81125";
        verifiedControl.style.backgroundColor = "#FEDEE2";
        element.style.borderColor = "#B81125";
        element.style.backgroundColor = "#FEDEE2";
    }
    else {
        verifiedControl.value = "True";
        verifiedControl.style.borderColor = "#67E46F";
        verifiedControl.style.backgroundColor = "#DFFFE1";
        element.style.borderColor = "#67E46F";
        element.style.backgroundColor = "#DFFFE1";
    }
}

function highlightResult(element) {
    if (element.className.indexOf("red") != -1) element.style.borderColor = "#B81125";
    else if (element.className.indexOf("green") != -1) element.style.borderColor = "#67E46F";
}

function normalResult(element) {
    element.style.borderColor = "#FFF";
}

function swapBgImage(element) {
	var image;
	var initialImage;
	if (element.currentStyle) {
	    initialImage = element.currentStyle.backgroundImage;
	}
	else {
	    initialImage = getComputedStyle(element, '').getPropertyValue('background-image');
	}
	if (initialImage.indexOf("Over") != -1) {
	    image = initialImage.replace("Over", "");
	    element.style.color = "#FFFF83";
	}
	else {
	    image = initialImage.replace(".png", "Over.png");
	    if (initialImage.indexOf("Down") == -1) element.style.color = "#B81125";
	    else element.style.color = "#11B71C";
	}
	element.style.backgroundImage = image;
}

function swapImage(element) {
    var image;
	var initialImage = element.src;
	if (initialImage.indexOf("Over") != -1) {
	    image = initialImage.replace("Over", "");
	}
	else {
	    image = initialImage.replace(".png", "Over.png");
	}
	element.src = image;
}

function swapBackgroundImage(element) {
    var image;
    var initialImage;
    if (element.currentStyle) {
        initialImage = element.currentStyle.backgroundImage;
    }
    else {
        initialImage = getComputedStyle(element, '').getPropertyValue('background-image');
    }
    if (initialImage.indexOf("Over") != -1) {
        image = initialImage.replace("Over", "");
    }
    else {
        image = initialImage.replace(".png", "Over.png");
    }
    element.style.backgroundImage = image;
}

// Google map & Contact page

function initializeMap() {
    showOffice(1);
}

function setMap(latitude, longditude) {
    var latlng = new google.maps.LatLng(latitude, longditude);
    var myOptions = {
        zoom: 15,
        center: latlng,
        mapTypeId: google.maps.MapTypeId.ROADMAP
    };
    var map = new google.maps.Map(document.getElementById("googleMap"), myOptions);
    var marker = new google.maps.Marker({
        position: latlng,
        map: map,
        title: "Connections London office."
    });
}

function showOffice(index) {
    if (index == 1) {
        setMap(51.51971, -0.10565); // Farringdon Road
        document.getElementById("office1").setAttribute("class", "");
        document.getElementById("office2").setAttribute("class", "hidden");
    }
    else if (index == 2) {
        setMap(52.47690, -1.90023); // Hill Street
        document.getElementById("office1").setAttribute("class", "hidden");
        document.getElementById("office2").setAttribute("class", "");
    }
}

function highlightBorder(element) {
    element.style.borderColor = "#67E46F";
}

function normalBorder(element) {
    element.style.borderColor = "#B81125";
}
